package com.xiong.xtools.like;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.xiong.xtools.R;

import java.util.Random;
/**
 * Author : 熊文强
 * Time : 2017/9/19
 * Content : 自定义点赞控件，直播点赞气泡控件
 */
public class ActivityLike extends AppCompatActivity {

    RxShineButton mRxShineButton;
    RxShineButton porterShapeImageView1;
    RxShineButton porterShapeImageView2;
    RxShineButton porterShapeImageView3;
	RxShineButton porterShapeImageView4;
    LinearLayout mLlTop;
    LinearLayout mWrapper;
    RxShineButton mPoImage8;
    ImageView mLove;
    LinearLayout mLlControl;
    LinearLayout mLlBottom;
    RxHeartLayout mRxHeartLayout;
    TextView mTvHv;
    RelativeLayout mActivityLike;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_like);

		findView();

        mRxShineButton.init(this);
        porterShapeImageView1.init(this);
        porterShapeImageView2.init(this);
        porterShapeImageView3.init(this);
		porterShapeImageView4.init(this);

        RxShineButton rxShineButtonJava = new RxShineButton(this);

        rxShineButtonJava.setBtnColor(Color.GRAY);
        rxShineButtonJava.setBtnFillColor(Color.RED);
        rxShineButtonJava.setShapeResource(R.raw.like_heart);
        rxShineButtonJava.setAllowRandomColor(true);
        rxShineButtonJava.setShineSize(100);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(100, 100);
        rxShineButtonJava.setLayoutParams(layoutParams);
        if (mWrapper != null) {
            mWrapper.addView(rxShineButtonJava);
        }


        mRxShineButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
        mRxShineButton.setOnCheckStateChangeListener(new RxShineButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(View view, boolean checked) {
            }
        });

        porterShapeImageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
        porterShapeImageView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });

    }

	private void findView() {
		mRxShineButton = (RxShineButton) findViewById(R.id.po_image0);
		porterShapeImageView1 = (RxShineButton) findViewById(R.id.po_image1);
		porterShapeImageView2 = (RxShineButton) findViewById(R.id.po_image2);
		porterShapeImageView3 = (RxShineButton) findViewById(R.id.po_image3);
		porterShapeImageView4 = (RxShineButton) findViewById(R.id.po_image4);
		mLlTop = (LinearLayout) findViewById(R.id.ll_top);
		mWrapper = (LinearLayout) findViewById(R.id.wrapper);
		mPoImage8 = (RxShineButton) findViewById(R.id.po_image8);
		mLove = (ImageView) findViewById(R.id.love);
		mLlControl = (LinearLayout) findViewById(R.id.ll_control);
		mLlBottom = (LinearLayout) findViewById(R.id.ll_bottom);
		mRxHeartLayout = (RxHeartLayout) findViewById(R.id.heart_layout);
		mTvHv = (TextView) findViewById(R.id.tv_hv);
		mActivityLike = (RelativeLayout) findViewById(R.id.activity_like);

		mLove.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				mRxHeartLayout.post(new Runnable() {
					@Override
					public void run() {
						int rgb = Color.rgb(random.nextInt(255), random.nextInt(255), random.nextInt(255));
						mRxHeartLayout.addHeart(rgb);
					}
				});
			}
		});
	}

	private Random random = new Random();

}
